<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.util.*,hotel.entity.*"%>
<%@include file="../link.html"%>
<!DOCTYPE html>
<script type="text/javascript">
layui.use('laydate', function(){
	var start = layui.laydate;
	start.render({
		elem: '#start_end', //指定元素
		type: 'datetime',
		format: 'yyyy-MM-dd HH:mm:ss',
		range : '~',
		done: function(value, date, endDate){
		    $('#start_time').val(value.substring(0,16));
		    $('#end_time').val(value.substring(19));
		}
	});
});

$(document).ready(function() {
	$("#btn-close").click( function () { 
		var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
		parent.layer.close(index); //再执行关闭 
	});
});

function editReserve(){
	var index=$('#btn-submit').attr('class').indexOf("disabled");
	if(index==-1){//disabled的下标为-1说明确定按钮可用
		$.ajax({
	        type:"post",
	        url:"editReserve",
	        data: $('#form').serialize(),//表单数据
	        success: function(data){
	        	layer.msg('修改成功',{time:1000,icon:1});
	        }
	    });
	}
	return false;
}
</script>

<div style="padding-top:20px;">
	<form id="reserveForm" action="addReserve" method="post" class="form-horizontal" 
	data-toggle="validator" role="form">
		<input type="hidden" name="operateUser.userid" value="${reserve.operateUser.userid}">
		<input type="hidden" name="reserveTime" value="${reserve.reserveTime}">
		<input type="hidden" id="start_time" name="start_time" value="${reserve.start_time}">
		<input type="hidden" id="end_time" name="end_time" value="${reserve.end_time}">
		
		<div class="form-group">
			<label class="col-sm-4 control-label">预定房间类型</label>
			<div class="col-sm-6">
				<select name="category.categoryid" class="form-control">
				<%
				List<Category> list=(List<Category>)request.getAttribute("categoryList");
				if(list!=null&&list.size()>0)
					for(Category c:list)
						out.print("<option value='"+c.getCategoryid()+"'>"
						+c.getCategoryName()+"</option>");
				%>
				</select>
			</div>
			<div class="help-block with-errors"></div>
		</div>
		
		<div class="form-group">
			<label class="col-sm-4 control-label">预定房间数量</label>
			<div class="col-sm-6">
				<input id="amount" name="amount" class="form-control" 
				type="number" value="${reserve.amount}" min="1" max="10" required>
			</div>
			<div class="help-block with-errors"></div>
		</div>
		
		<div class="form-group">
			<label class="col-sm-4 control-label">预订人姓名</label>
			<div class="col-sm-6">
				<input id="userName" name="userName" class="form-control" 
				value="${reserve.userName}" required>
			</div>
			<div class="help-block with-errors"></div>
		</div>
		
		<div class="form-group">
			<label class="col-sm-4 control-label">联系电话</label>
			<div class="col-sm-6">
				<input id="tele" name="tele" class="form-control" value="${reserve.tele}" required>
			</div>
			<div class="help-block with-errors"></div>
		</div>
		
		<div class="form-group">
			<label class="col-sm-4 control-label">预计入离时间</label>
			<div class="col-sm-6">
				<div class="input-group date">
					<div class="input-group-addon"> <i class="fa fa-calendar"></i> </div>
					<input type="text" class="form-control pull-right" id="start_end" value="${reserve.start_time} ~ ${reserve.end_time}">
				</div>
			</div> 
		</div>
		
		<div class="box-footer"></div>
		
		<div class="form-group">
			<label class="col-sm-4 control-label"></label>
			<div class="col-sm-6">
				<div class="pull-right">
					<button id="btn-submit" type="submit" class="btn btn-primary" onClick="return editReserve()">
						<i class="fa fa-floppy-o "></i> 确定
					</button>
					<button id="btn-close" class="btn btn-close btn-primary" type="button">
						<i class="fa fa-remove"></i> 关闭
					</button>
				</div>
			</div>
		</div>
	</form>
</div>